/**
 * @ Author: luoqi
 * @ Create Time: 2024-11-27 10:32
 * @ Modified by: luoqi
 * @ Modified time: 2025-02-11 09:34
 * @ Description:
 */

#ifndef _STATISTICS_H
#define _STATISTICS_H

#include <stdint.h>

#ifndef qfp_t
typedef float qfp_t;
#endif

typedef struct {
    uint32_t cnt;
    uint32_t times;
    qfp_t sum;
    qfp_t rms;
} RmsObj;

int rms_init(RmsObj *obj, uint32_t times);

qfp_t rms_update(RmsObj *obj, qfp_t data);

qfp_t rms_calc(qfp_t *data, uint32_t size);

typedef struct {
    uint32_t cnt;
    uint32_t times;
    qfp_t sum;
    qfp_t avg;
} AvgObj;

int avg_init(AvgObj *obj, uint32_t times);

qfp_t avg_update(AvgObj *obj, qfp_t data);

qfp_t avg_calc(qfp_t *data, uint32_t size);

#endif
